#!/usr/bin/env python
# coding: utf-8

# In[1]:


import requests
import kuser_agent as kua
import ktool
import pandas as pd
data = []
content = requests.get(url='https://www.runoob.com/html/html-tutorial.html', headers={'User-Agent': kua.get()}).content

all_a = ktool.xpath.xpath_all(content, '//div[@id="leftcolumn"]/a')
for item in all_a:
    data.append({
        '名称': ktool.xpath.xpath_union(item, 'text()'),
        '地址': 'https://www.runoob.com/' + ktool.xpath.xpath_union(item, '@href')
    })
pd_data = pd.DataFrame(data)
pd_data.to_excel('cai.xlsx')


# In[ ]:




